import qs from 'qs'

let BASEURL = "https://wzgapi.shaoyue5.com"

var header = {
    systemType: "ios",
}

var opt = {
    header,
    "Accept": "application/json",
    "Content-Type": "application/json"
}

let net = {
    get: async (path, data) => {
        let res = null
        if (data != null && data != undefined) {
            res = await fetch(`${BASEURL}${path}?${qs.stringify(data)}`, opt)
        } else {
            res = await fetch(`${BASEURL}${path}`, opt)
        }
        return await res.json()
    },
    post: async (path, data) => {
        opt.method = 'POST'
        opt.body = JSON.stringify(data)
        let res = await fetch(`${BASEURL}${path}`, opt)
        return await res.json()
    }
}

export default net